/**
 * Object.create(proto[, propertiesObject])

 proto
 新创建对象的原型对象。



 */


//用 Object.create实现类式继承
function Parent(pswd){
    this.pswd = pswd
    this.value = '123'
    this.arr = [1,2]
    console.log('调用父类构造函数...')
}
Parent.prototype.say = function(){
    console.log(this.pswd,this.value)
}

function Child(pswd){
    Parent.call(this,pswd)
}
Child.prototype = Object.create(Parent.prototype)
Child.prototype.constructor = Child
Child.prototype.show=function(){
    console.log('Child1.show...')
}

function Child2(pswd){
    Parent.call(this,pswd)
}
Child2.prototype = Object.create(Parent.prototype)
Child2.prototype.constructor = Child2
Child2.prototype.show=function(){
    console.log('Child2.show...')
}

console.log()
console.log('实例化Child一个child1...')
const child1 = new Child('密码')
console.log('child1继承父的属性：',child1.pswd);
child1.say() // parent say...
console.log(child1.constructor); // [Function: Child]
console.log(child1 instanceof Parent) // true
console.log(child1 instanceof Child) // true

console.log()
console.log('实例化Child一个child2...')
const child2 = new Child('密码')

child2.arr.push(3)

console.log('child1.arr',child1.arr) // [1,2]
console.log('child2.arr',child2.arr) // [1,2,3] // 不影响另外一个子实例

console.log()
console.log('实例化Child2一个child3...')
const child3 = new Child2('密码')

console.log()
child1.show() // Child1.show...
child2.show() // Child1.show...
child3.show() // Child2.show...
